<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>珠峰架构师成长计划</title>
    <link rel="stylesheet" type="text/css" href="../static/css/main.css">
</head>
<body>
<div class="nav">
    <div class="logo">
        
            珠峰架构师成长计划
        
    </div>
<ul><li><a href="../index.html">0.Async</a></li><li><a href="../html/0.editor.html">0.editor</a></li><li><a href="../html/0.module.html">0.module</a></li><li><a href="../html/1.ES2015.html">1.ES2015</a></li><li><a href="../html/2.Promise.html">2.Promise</a></li><li><a href="../html/3.Node.html">3.Node</a></li><li><a href="../html/4.NodeInstall.html">4.NodeInstall</a></li><li><a href="../html/5.REPL.html">5.REPL</a></li><li><a href="../html/6.NodeCore.html">6.NodeCore</a></li><li><a href="../html/7.module&NPM.html">7.module&NPM</a></li><li><a href="../html/8.Encoding.html">8.Encoding</a></li><li><a href="../html/9.Buffer.html">9.Buffer</a></li><li><a href="../html/10.fs.html">10.fs</a></li><li><a href="../html/11.Stream-1.html">11.Stream-1</a></li><li><a href="../html/11.Stream-2.html">11.Stream-2</a></li><li><a href="../html/11.Stream-3.html">11.Stream-3</a></li><li><a href="../html/11.Stream-4.html">11.Stream-4</a></li><li><a href="../html/12-Network-2.html">12-Network-2</a></li><li><a href="../html/12.NetWork-3.html">12.NetWork-3</a></li><li><a href="../html/12.Network-1.html">12.Network-1</a></li><li><a href="../html/13.tcp.html">13.tcp</a></li><li><a href="../html/14.http-1.html">14.http-1</a></li><li><a href="../html/14.http-2.html">14.http-2</a></li><li><a href="../html/15.compress.html">15.compress</a></li><li><a href="../html/16.crypto.html">16.crypto</a></li><li><a href="../html/17.process.html">17.process</a></li><li><a href="../html/18.yargs.html">18.yargs</a></li><li><a href="../html/19.cache.html">19.cache</a></li><li><a href="../html/20.action.html">20.action</a></li><li><a href="../html/21.https.html">21.https</a></li><li><a href="../html/22.cookie.html">22.cookie</a></li><li><a href="../html/23.session.html">23.session</a></li><li><a href="../html/24.express-1.html">24.express-1</a></li><li><a href="../html/24.express-2.html">24.express-2</a></li><li><a href="../html/24.express-3.html">24.express-3</a></li><li><a href="../html/24.express-4.html">24.express-4</a></li><li><a href="../html/25.koa-1.html">25.koa-1</a></li><li><a href="../html/26.webpack-1-basic.html">26.webpack-1-basic</a></li><li><a href="../html/26.webpack-2-optimize.html">26.webpack-2-optimize</a></li><li><a href="../html/26.webpack-3.tapable.html">26.webpack-3.tapable</a></li><li><a href="../html/26.webpack-4-AST.html">26.webpack-4-AST</a></li><li><a href="../html/26.webpack-5-source.html">26.webpack-5-source</a></li><li><a href="../html/26.webpack-6-loader.html">26.webpack-6-loader</a></li><li><a href="../html/26.webpack-7-plugin.html">26.webpack-7-plugin</a></li><li><a href="../html/26.webpack-8-hand.html">26.webpack-8-hand</a></li><li><a href="../html/27.react-1.html">27.react-1</a></li><li><a href="../html/27.react-2.html">27.react-2</a></li><li><a href="../html/27.react-3.html">27.react-3</a></li><li><a href="../html/27.react-4-immutable.html">27.react-4-immutable</a></li><li><a href="../html/27.react-5-react-dom-diff.html">27.react-5-react-dom-diff</a></li><li><a href="../html/27.react-6.html">27.react-6</a></li><li><a href="../html/28.react-mobx.html">28.react-mobx</a></li><li><a href="../html/28.redux-0.html">28.redux-0</a></li><li><a href="../html/28.redux-1.html">28.redux-1</a></li><li><a href="../html/28.redux-2-中间件.html">28.redux-2-中间件</a></li><li><a href="../html/28.redux-3-saga.html">28.redux-3-saga</a></li><li><a href="../html/28.redux-jwt-back.html">28.redux-jwt-back</a></li><li><a href="../html/28.redux-jwt-front.html">28.redux-jwt-front</a></li><li><a href="../html/29.mongodb-1.html">29.mongodb-1</a></li><li><a href="../html/29.mongodb-2.html">29.mongodb-2</a></li><li><a href="../html/29.mongodb-3.html">29.mongodb-3</a></li><li><a href="../html/29.mongodb-4.html">29.mongodb-4</a></li><li><a href="../html/29.mongodb-5.html">29.mongodb-5</a></li><li><a href="../html/29.mongodb-6.html">29.mongodb-6</a></li><li><a href="../html/30.cms-1-mysql.html">30.cms-1-mysql</a></li><li><a href="../html/30.cms-2-mysql.html">30.cms-2-mysql</a></li><li><a href="../html/30.cms-3-mysql.html">30.cms-3-mysql</a></li><li><a href="../html/30.cms-4-egg.html">30.cms-4-egg</a></li><li><a href="../html/30.cms-5-api.html">30.cms-5-api</a></li><li><a href="../html/30.cms-6-roadhog.html">30.cms-6-roadhog</a></li><li><a href="../html/30.cms-7-umi.html">30.cms-7-umi</a></li><li><a href="../html/30.cms-8-dva.html">30.cms-8-dva</a></li><li><a href="../html/30.cms-9-dva.html">30.cms-9-dva</a></li><li><a href="../html/30.cms-10-front.html">30.cms-10-front</a></li><li><a href="../html/30.cms-11-deploy.html">30.cms-11-deploy</a></li><li><a href="../html/33.redis.html">33.redis</a></li><li><a href="../html/34.unittest.html">34.unittest</a></li><li><a href="../html/35.jwt.html">35.jwt</a></li><li><a href="../html/36.websocket-1.html">36.websocket-1</a></li><li><a href="../html/36.websocket-2.html">36.websocket-2</a></li><li><a href="../html/38.chat-api-1.html">38.chat-api-1</a></li><li><a href="../html/38.chat-api-2.html">38.chat-api-2</a></li><li><a href="../html/38.chat-3.html">38.chat-3</a></li><li><a href="../html/38.chat-api-3.html">38.chat-api-3</a></li><li><a href="../html/38.chat.html">38.chat</a></li><li><a href="../html/38.chat2.html">38.chat2</a></li><li><a href="../html/38.chat2.html">38.chat2</a></li><li class="active"><a href="../html/39.crawl-0.html">39.crawl-0</a></li><li><a href="../html/39.crawl-1.html">39.crawl-1</a></li><li><a href="../html/39.crawl-2.html">39.crawl-2</a></li><li><a href="../html/40.deploy.html">40.deploy</a></li><li><a href="../html/41.safe.html">41.safe</a></li><li><a href="../html/42.test.html">42.test</a></li><li><a href="../html/43.nginx.html">43.nginx</a></li><li><a href="../html/44.enzyme.html">44.enzyme</a></li><li><a href="../html/45.docker.html">45.docker</a></li><li><a href="../html/46.elastic.html">46.elastic</a></li><li><a href="../html/47.oauth.html">47.oauth</a></li><li><a href="../html/48.wxpay.html">48.wxpay</a></li><li><a href="../html/49.nunjucks.html">49.nunjucks</a></li><li><a href="../html/50.ketang.html">50.ketang</a></li><li><a href="../html/index.html">index</a></li><li><a href="../html/51.typescript.html">51.typescript</a></li><li><a href="../html/52.UML.html">52.UML</a></li><li><a href="../html/53.design.html">53.design</a></li><li><a href="../html/index.html">index</a></li><li><a href="../html/54.linux.html">54.linux</a></li><li><a href="../html/55.yaml.html">55.yaml</a></li><li><a href="../html/50.ketang2.html">50.ketang2</a></li><li><a href="../html/56.ts.html">56.ts</a></li><li><a href="../html/57.ts_react.html">57.ts_react</a></li><li><a href="../html/58.react-ssr.html">58.react-ssr</a></li><li><a href="../html/59.react-ssr.html">59.react-ssr</a></li></ul></div>


<div class="warpper">

    <div class="page-toc">
        <ul><li><a href="#t01. 爬取内容">1. 爬取内容</a><ul><li><a href="#t11. http/axios 等爬取API接口">1. http/axios 等爬取API接口</a></li><li><a href="#t22. superagent/request/crawl爬取HTML页面">2. superagent/request/crawl爬取HTML页面</a></li><li><a href="#t33. 使用puppeteer控制chromium">3. 使用puppeteer控制chromium</a></li></ul></li><li><a href="#t42.数据持久化">2.数据持久化</a></li><li><a href="#t53. 数据订阅">3. 数据订阅</a></li><li><a href="#t64. 分发">4. 分发</a></li><li><a href="#t7参考">参考</a></li></ul>
    </div>
    
    <div class="content markdown-body">
        <h2 id="t01. &#x722C;&#x53D6;&#x5185;&#x5BB9;">1. &#x722C;&#x53D6;&#x5185;&#x5BB9; <a href="#t01. &#x722C;&#x53D6;&#x5185;&#x5BB9;"> # </a></h2>
<h3 id="t11. http/axios &#x7B49;&#x722C;&#x53D6;API&#x63A5;&#x53E3;">1. http/axios &#x7B49;&#x722C;&#x53D6;API&#x63A5;&#x53E3; <a href="#t11. http/axios &#x7B49;&#x722C;&#x53D6;API&#x63A5;&#x53E3;"> # </a></h3>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> axios = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;axios&apos;</span>);
axios.get(<span class="hljs-string">&apos;https://follow-api-ms.juejin.im/v1/getUserFollowInfo?uid=551d6923e4b0cd5b623f54da&amp;src=web&apos;</span>)
    .then(<span class="hljs-function"><span class="hljs-params">res</span> =&gt;</span> <span class="hljs-built_in">console</span>.log(res.data))
</code></pre>
<h3 id="t22. superagent/request/crawl&#x722C;&#x53D6;HTML&#x9875;&#x9762;">2. superagent/request/crawl&#x722C;&#x53D6;HTML&#x9875;&#x9762; <a href="#t22. superagent/request/crawl&#x722C;&#x53D6;HTML&#x9875;&#x9762;"> # </a></h3>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> request = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;request&apos;</span>);
request(<span class="hljs-string">&apos;https://juejin.im/tag/%E5%89%8D%E7%AB%AF&apos;</span>, (err, response, body) =&gt; {
    <span class="hljs-keyword">let</span> regexp = <span class="hljs-regexp">/class=&quot;title&quot; data-v-\w+&gt;(.+?)&lt;\/a&gt;/g</span>;
    <span class="hljs-keyword">let</span> titles = [];
    body.replace(regexp, (matched, title) =&gt; {
        titles.push(title);
    });
    <span class="hljs-built_in">console</span>.log(titles);
});
</code></pre>
<h3 id="t33. &#x4F7F;&#x7528;puppeteer&#x63A7;&#x5236;chromium">3. &#x4F7F;&#x7528;puppeteer&#x63A7;&#x5236;chromium <a href="#t33. &#x4F7F;&#x7528;puppeteer&#x63A7;&#x5236;chromium"> # </a></h3>
<ul>
<li>puppeteer&#x662F;Chrome&#x56E2;&#x961F;&#x5F00;&#x53D1;&#x7684;&#x4E00;&#x4E2A;node&#x5E93;</li>
<li>&#x53EF;&#x4EE5;&#x901A;&#x8FC7;api&#x6765;&#x63A7;&#x5236;&#x6D4F;&#x89C8;&#x5668;&#x7684;&#x884C;&#x4E3A;&#xFF0C;&#x6BD4;&#x5982;&#x70B9;&#x51FB;&#xFF0C;&#x8DF3;&#x8F6C;&#xFF0C;&#x5237;&#x65B0;&#xFF0C;&#x5728;&#x63A7;&#x5236;&#x53F0;&#x6267;&#x884C;js&#x811A;&#x672C;&#x7B49;&#x7B49;</li>
<li>&#x901A;&#x8FC7;&#x8FD9;&#x4E2A;&#x5DE5;&#x5177;&#x53EF;&#x4EE5;&#x7528;&#x6765;&#x5199;&#x722C;&#x866B;&#xFF0C;&#x81EA;&#x52A8;&#x7B7E;&#x5230;&#xFF0C;&#x7F51;&#x9875;&#x622A;&#x56FE;&#xFF0C;&#x751F;&#x6210;pdf&#xFF0C;&#x81EA;&#x52A8;&#x5316;&#x6D4B;&#x8BD5;&#x7B49;</li>
</ul>
<pre><code class="lang-js">(<span class="hljs-keyword">async</span> () =&gt; {
     <span class="hljs-keyword">const</span> browser = <span class="hljs-keyword">await</span> puppeteer.launch();<span class="hljs-comment">//&#x6253;&#x5F00;&#x6D4F;&#x89C8;&#x5668;</span>
     <span class="hljs-keyword">const</span> page = <span class="hljs-keyword">await</span> browser.newPage();<span class="hljs-comment">//&#x6253;&#x5F00;&#x4E00;&#x4E2A;&#x7A7A;&#x767D;&#x9875;</span>
     <span class="hljs-keyword">await</span> page.goto(<span class="hljs-string">&apos;https://www.baidu.com&apos;</span>);<span class="hljs-comment">//&#x5728;&#x5730;&#x5740;&#x680F;&#x8F93;&#x5165;&#x7F51;&#x5740;&#x5E76;&#x7B49;&#x5F85;&#x52A0;&#x8F7D;</span>
     <span class="hljs-keyword">await</span> page.screenshot({ <span class="hljs-attr">path</span>: <span class="hljs-string">&apos;baidu.png&apos;</span> });<span class="hljs-comment">//&#x622A;&#x4E2A;&#x56FE;</span>
     <span class="hljs-keyword">await</span> browser.close();<span class="hljs-comment">//&#x5173;&#x6389;&#x6D4F;&#x89C8;&#x5668;</span>
})();
</code></pre>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> puppeteer=<span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;puppeteer&apos;</span>);
<span class="hljs-keyword">const</span> fs=<span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;fs&apos;</span>);
(<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
        <span class="hljs-keyword">const</span> browser=<span class="hljs-keyword">await</span> puppeteer.launch({<span class="hljs-attr">headless</span>:<span class="hljs-literal">false</span>});
        <span class="hljs-keyword">const</span> page=<span class="hljs-keyword">await</span> browser.newPage();
        <span class="hljs-keyword">await</span> page.goto(<span class="hljs-string">&apos;https://juejin.im/tag/%E5%89%8D%E7%AB%AF&apos;</span>, {
<span class="hljs-attr">waitUntil</span>: <span class="hljs-string">&apos;networkidle2&apos;</span>
        });
        <span class="hljs-keyword">await</span> page.waitFor(<span class="hljs-number">500</span>);
        <span class="hljs-keyword">let</span> comments = <span class="hljs-keyword">await</span> page.$$<span class="hljs-built_in">eval</span>(<span class="hljs-string">&apos;a.title&apos;</span>, els =&gt; {
<span class="hljs-keyword">return</span> els.map(<span class="hljs-function"><span class="hljs-params">item</span> =&gt;</span> item.innerText);
        });
        fs.writeFileSync(<span class="hljs-string">&apos;comments.txt&apos;</span>,comments.join(<span class="hljs-string">&apos;\r\n&apos;</span>),<span class="hljs-string">&apos;utf8&apos;</span>);
        <span class="hljs-keyword">await</span> browser.close();
})();
</code></pre>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> puppeteer=<span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;puppeteer&apos;</span>);
(<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">const</span> browser=<span class="hljs-keyword">await</span> puppeteer.launch({<span class="hljs-attr">headless</span>:<span class="hljs-literal">false</span>});<span class="hljs-comment">//&#x542F;&#x52A8;&#x6D4F;&#x89C8;&#x5668;</span>
    <span class="hljs-keyword">let</span> page = <span class="hljs-keyword">await</span> browser.newPage();<span class="hljs-comment">//&#x521B;&#x5EFA;&#x4E00;&#x4E2A; Page &#x5B9E;&#x4F8B;</span>
    <span class="hljs-keyword">await</span> page.setJavaScriptEnabled(<span class="hljs-literal">true</span>);<span class="hljs-comment">//&#x542F;&#x7528;javascript</span>
    <span class="hljs-keyword">await</span> page.goto(<span class="hljs-string">&quot;https://www.jd.com/&quot;</span>);
    <span class="hljs-keyword">const</span> searchInput = <span class="hljs-keyword">await</span> page.$(<span class="hljs-string">&quot;#key&quot;</span>);<span class="hljs-comment">//&#x83B7;&#x53D6;&#x5143;&#x7D20;</span>
    <span class="hljs-keyword">await</span> searchInput.focus(); <span class="hljs-comment">//&#x5B9A;&#x4F4D;&#x5230;&#x641C;&#x7D22;&#x6846;</span>
    <span class="hljs-keyword">await</span> page.keyboard.type(<span class="hljs-string">&quot;&#x624B;&#x673A;&quot;</span>);<span class="hljs-comment">//&#x8F93;&#x5165;&#x624B;&#x673A;</span>
    <span class="hljs-keyword">const</span> searchBtn = <span class="hljs-keyword">await</span> page.$(<span class="hljs-string">&quot;.button&quot;</span>);
    <span class="hljs-keyword">await</span> searchBtn.click();
    <span class="hljs-keyword">await</span> page.waitForSelector(<span class="hljs-string">&apos;.gl-item&apos;</span>); <span class="hljs-comment">//&#x7B49;&#x5F85;&#x5143;&#x7D20;&#x52A0;&#x8F7D;&#x4E4B;&#x540E;&#xFF0C;&#x5426;&#x5219;&#x83B7;&#x53D6;&#x4E0D;&#x4E86;&#x5F02;&#x6B65;&#x52A0;&#x8F7D;&#x7684;&#x5143;&#x7D20;</span>
    <span class="hljs-keyword">const</span> links = <span class="hljs-keyword">await</span> page.$$<span class="hljs-built_in">eval</span>(<span class="hljs-string">&apos;.gl-item &gt; .gl-i-wrap &gt; .p-img &gt; a&apos;</span>, links =&gt; {
        <span class="hljs-keyword">return</span> links.map(<span class="hljs-function"><span class="hljs-params">a</span> =&gt;</span> {
            <span class="hljs-keyword">return</span> {
                <span class="hljs-attr">href</span>: a.href.trim(),
                <span class="hljs-attr">title</span>: a.title
            }
        });
    });
    page.close();
    <span class="hljs-keyword">const</span> aTags = links.splice(<span class="hljs-number">0</span>, <span class="hljs-number">1</span>);
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>; i &lt; aTags.length; i++) {
        page=<span class="hljs-keyword">await</span> browser.newPage();
        page.setJavaScriptEnabled(<span class="hljs-literal">true</span>);
        <span class="hljs-keyword">await</span> page.setViewport({<span class="hljs-comment">//&#x4FEE;&#x6539;&#x6D4F;&#x89C8;&#x5668;&#x89C6;&#x7A97;&#x5927;&#x5C0F;</span>
            width: <span class="hljs-number">1920</span>,
            <span class="hljs-attr">height</span>: <span class="hljs-number">1080</span>
        });
        <span class="hljs-keyword">var</span> a = aTags[i];
        <span class="hljs-keyword">await</span> page.goto(a.href, {<span class="hljs-attr">timeout</span>: <span class="hljs-number">0</span>});
        <span class="hljs-keyword">let</span> filename = <span class="hljs-string">&quot;items-&quot;</span> + i + <span class="hljs-string">&quot;.png&quot;</span>;
        <span class="hljs-keyword">await</span> page.screenshot({
            <span class="hljs-attr">path</span>: filename,
            <span class="hljs-attr">fullPage</span>: <span class="hljs-literal">true</span>
        });
        page.close();
    }
    browser.close();
})();
</code></pre>
<h2 id="t42.&#x6570;&#x636E;&#x6301;&#x4E45;&#x5316;">2.&#x6570;&#x636E;&#x6301;&#x4E45;&#x5316; <a href="#t42.&#x6570;&#x636E;&#x6301;&#x4E45;&#x5316;"> # </a></h2>
<ul>
<li>&#x6839;&#x636E;&#x722C;&#x53D6;&#x7684;&#x89C4;&#x5219;&#x548C;&#x7B56;&#x7565;&#xFF0C;&#x628A;&#x722C;&#x53D6;&#x5230;&#x7684;&#x6570;&#x636E;&#x50A8;&#x5230;&#x6570;&#x636E;&#x5E93;&#x4E2D;</li>
<li>&#x5982;&#x679C;&#x8981;&#x517C;&#x5BB9;&#x4E0D;&#x540C;&#x7684;&#x6765;&#x6E90;&#xFF0C;&#x9700;&#x8981;&#x5BF9;&#x6570;&#x636E;&#x9700;&#x8981;&#x683C;&#x5F0F;&#x5316;</li>
<li>&#x4E3A;&#x4E0D;&#x540C;&#x7684;&#x6570;&#x636E;&#x5EFA;&#x7ACB;&#x7D22;&#x5F15;&#x65B9;&#x4FBF;&#x68C0;&#x7D22;</li>
</ul>
<h2 id="t53. &#x6570;&#x636E;&#x8BA2;&#x9605;">3. &#x6570;&#x636E;&#x8BA2;&#x9605; <a href="#t53. &#x6570;&#x636E;&#x8BA2;&#x9605;"> # </a></h2>
<ul>
<li>&#x7528;&#x6237;&#x53EF;&#x4EE5;&#x6309;&#x7167;&#x81EA;&#x5DF1;&#x7684;&#x5174;&#x8DA3;&#x548C;&#x9700;&#x8981;&#x8FDB;&#x884C;&#x8BA2;&#x5236;&#x5185;&#x5BB9;</li>
</ul>
<h2 id="t64. &#x5206;&#x53D1;">4. &#x5206;&#x53D1; <a href="#t64. &#x5206;&#x53D1;"> # </a></h2>
<p>&#x6709;&#x65B0;&#x7684;&#x6570;&#x636E;&#x7684;&#x65F6;&#x5019;</p>
<ul>
<li>&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x90AE;&#x4EF6;&#x63A8;&#x9001;&#x5230;&#x8BA2;&#x9605;&#x8005;</li>
<li>&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x6781;&#x5149;&#x63A8;&#x9001;&#x7B49;&#x63A8;&#x9001;&#x670D;&#x52A1;</li>
<li>&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x53CA;&#x65F6;&#x901A;&#x4FE1;&#x670D;&#x52A1;&#x5411;&#x5BA2;&#x6237;&#x7AEF;&#x63A8;&#x9001;</li>
</ul>
<h2 id="t7&#x53C2;&#x8003;">&#x53C2;&#x8003; <a href="#t7&#x53C2;&#x8003;"> # </a></h2>
<ul>
<li><a href="https://www.npmjs.com/package/axios">axios</a></li>
<li><a href="https://www.npmjs.com/package/request">request</a></li>
<li><a href="https://github.com/GoogleChrome/puppeteer">puppeteer</a></li>
<li><a href="https://github.com/GoogleChrome/puppeteer/blob/v1.7.0/docs/api.md">puppeteer api</a></li>
<li><a href="https://www.showapi.com/api/view/184/4">showapi</a> </li>
</ul>

        <div class="copyright">Powered by <a href="https://github.com/jaywcjlove/idoc" target="_blank">idoc</a>. Dependence <a href="https://nodejs.org">Node.js</a> run.</div>
    </div>
    
</div>

<script src="https://cdn.bootcss.com/jquery/3.0.0/jquery.js"></script>
<script>
$('.warpper .page-toc ul ul li a').on('click',function(){
  $('.warpper .page-toc ul ul li a').removeClass('my-active')
  $(this).addClass('my-active')
})
  // if (!$('.understand-me').length) {
  //   var bar = $(window).height() - $('.navbar ').height() - $('.page-toc').position().top;
  //   var count = bar / 26 / 2;
  //   var barHeight = $('.page-toc').outerHeight();
  //   $('.page-toc li').eq(0).children('a').addClass('red');
  //   var arr = [];
  //   $("h1,h2,h3,h4,h5,h6").each(function () {
  //     arr.push($(this).position().top);
  //   });
  //   var timer
  //   function dark() {
  //     clearTimeout(timer)
  //      timer = setTimeout(function () {
  //      var top = Math.abs($('.page-toc > ul').position().top);
  //      var cur = $('.content').scrollTop();
  //      for (var i = arr.length; i >= 0; i--) {
  //        if (arr[i] <= cur) {
  //          break;
  //        }
  //      }
  //      if (i === -1) {
  //        i = 0;
  //      }
  //      $('.page-toc li a').removeClass('red');
  //      $('.page-toc li').eq(i).children('a').addClass('red');
  //      let height = $('.page-toc li').eq(i).position().top-$('.page-toc').height(); // 如果当前的offset出去了 回到中间可好？
  //      $('.page-toc').scrollTop(height+$('.page-toc').height()/2);
  //    },200)
  //   }

  //   $('.content').on('scroll', dark);
  // }
</script>
<style>

    /* ::-webkit-scrollbar{width:14px;}
    ::-webkit-scrollbar-track{background-color:transparent;}
    ::-webkit-scrollbar-thumb{background-color:transparent;}
    ::-webkit-scrollbar-thumb:hover {background-color:transparent}
    ::-webkit-scrollbar-thumb:active {background-color:transparent} */

    .page-toc > ul .red {
        background: #f3f3f3;
        z-index: 1;
        border-left: 3px solid #009a61;
        -webkit-transition: all .2s ease;
        transition: all .2s ease;
        color: #000
    }





</style>
</body>
</html>
